home *** CD-ROM | disk | FTP | other *** search
-
- # EStrAdd(r3:PTR TO ESTRING,r4:PTR TO CHAR,r5=-1:LONG)
-
- .text
- .global _EStrAdd
-
- _EStrAdd:
- and. r0,r3,r4 # have pointers?
- beq+ .finish
- cmpwi r5,0
- beq+ .finish
- lhz r6,-2(r3) # actual dst length
- lhz r7,-4(r3) # maximal dst length
- add r8,r3,r6 # r8 contains address of the zero byte in dst
- sub r7,r7,r6
- subi r7,r7,1 # r7 contains maximal length of the adding string
- cmpwi r5,0
- bgt+ .skip1
- b .skip # the copy size is negative => copy all (means: don't change r7)
- .skip1: subi r5,r5,1
- cmpw r7,r5
- ble+ .skip
- mr r7,r5 # r7 contains total number of characters to add
- .skip: subi r8,r8,1 # just to allow the lbzu r8,r8,#1#
- subi r4,r4,1 # just to allow the lbzu r4,r4,#1#
- .loop: lbzu r0,1(r4)
- stbu r0,1(r8) # add the character
- mr. r0,r0 # finished?
- beq+ .done
- addi r6,r6,1 # update the actual dst length
- subi r7,r7,1 # decrease the add count
- mr. r7,r7
- bge- .loop
- li r0,0
- stb r0,1(r8)
- .done: sth r6,-2(r3)
- .finish: blr
-
- .type _EStrAdd,@function
- .size _EStrAdd,$-_EStrAdd
-